<template>
	<div>
		<div class="word-container">
			<div class="forts">
				学生信息删除
				<el-button @click='goBack()' class="back-button">
					返回首页
				</el-button>
			</div>
			<Time class="forts-time" />
		</div>

		<!-- 学号输入框 -->
		<div class="input-bar-delete">
			<el-form ref="form" :model="inputSno" label-width="80px">
				<el-form-item label="学号">
					<el-input v-model="inputSno.sno"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="delete_row(inputSno)">删除</el-button>
				</el-form-item>
			</el-form>
		</div>
		<img src="../assets/logo.png" alt="" />
	</div>
</template>

<script>
	import {
		ElMessage
	} from 'element-plus'
	import Time from "./Time.vue";
	import {
		defineComponent,
		ref
	} from 'vue';
	export default {
		name: "StudentDelete",
		components: {
			Time,
			defineComponent,
			ref,
		},
		data() {
			return {
				inputSno: {
					sno: ''
				},
				tableData: {},
				}
			},
		methods: {
			goBack() {
				//直接跳转
				this.$router.push('/main');
			},
			delete_row(row) {
				ElMessage.success({
					message: '删除成功',
					type: 'success',
				})
				this.axios.post('http://localhost:8081/info/delete', {
					sno: row.sno
				}).then(response => {
					this.tableData = response.data
				})
			},
		},
	}
</script>

<style>
	.input-bar-delete {
		width: 30%;
		position: absolute;
		left: 10%;
		top: 35%;
	}

	.delete-button {
		width: 30%;
		position: absolute;
		left: 10%;
		top: 55%;
	}
</style>
